Repository navigation
test(hub): isolate Vitest state and worker databases - #112
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because there is no eligible user to bill.
An enterprise owner can allow the organization to be billed for reviews like this by enabling Copilot code review for users without a license.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename the maintenance workflow and checks to Scripts CI. Co-authored-by: Nishiki Liu <hello@nshki.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move Prisma schema and migrations to schema/. Co-authored-by: Nishiki Liu <hello@nshki.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Nishiki Liu <hello@nshki.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Nishiki Liu <hello@nshki.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
alliscode
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Hub contributors need independent test cases without repeating cleanup hooks in every file. Database tests also need to run in parallel without sharing records or clearing the development database. Closes #111.
This PR follows #108 in a native GitHub stack.
What changes
Shared setup resets test state before each case. It resets mocks, restores environment variables and real timers, and clears browser storage and leftover document content. Tests no longer repeat those cleanup hooks. They must still close resources they create, such as listeners and servers.
Vitest runs files in parallel and keeps cases within each worker sequential. Node.js and jsdom tests can opt into database access with
.db.test.tsor.db.test.tsxfiles. Database-enabled projects share the setup code but use separate databases per project and worker, prepared with the current Prisma schema. Before each case, setup clears application records and resets generated identity counters. It preserves migration records. Simultaneous runs use different database names, and cleanup drops only databases created by that run.npm testdoes not require PostgreSQL.npm run test:databaseselects bothnode-databaseandbrowser-databaseusingTEST_DATABASE_URL. Only this CI command starts PostgreSQL. The testing guide explains setup and cleanup and requires each case to arrange its own records, act, and assert.The schema and migration files live under
hub/schema/. Setup-only browser and database tests are removed. The database test command allows an empty project to pass; there are no database cases yet, so current runs do not exercise database setup.CI runs individual checks on every pull request, regardless of which files changed. Jobs no longer combine other jobs' results into a required check. Scripts CI checks the maintenance scripts independently. Hub's test jobs are named
Hub unit testsandHub database tests.Repository branch rules are unchanged. Maintainers must update required check names when adopting these workflows.